|
|
 |
|
|
|
|
dtBegin = #9/1/98#
dtTime = #10:10:00 AM#
intLoop = 10
lngID = 100000
sngQty = 2.5
dblAmount = 3.2233
curPrice = 500.65
strName = "Paul" |
|
|
|
|
|
|
|
|
Examples Filename: Vars.bas |
|
|
|
|
|
|
|
|
All the numeric values are pretty straightforward when youre doing the assignment statements. The Boolean value will accept the keyword True or False as an assignment. The Date and Time values are denoted with a pound sign (#), and a string value is enclosed by double quotes. You can find this code in the Vars.bas file. Look for the procedure called VariableAssignment in the Procedures combo box. |
|
|
|
|
|
|
|
|
Scope and Lifetime of a Variable |
|
|
|
|
|
|
|
|
When you declare a variable, you automatically determine a couple of characteristics of that variable. The first is its scopethat is, which procedures can view and change the contents of that variable. The second characteristic is the lifetime of the variablethat is, how long the value stays in memory. Table 6.2 shows the three types of scope a variable can have within a Visual Basic application. |
|
|
|
|
| Table 6.2 Scope Definitions. | | Scope | Description | | Global | A variable that can be viewed and changed by any routine within an application. | | Module level | A variable thats declared at the top of a form or standard module and can be viewed or changed by any routine within that module. | | Local | A variable thats declared within a routine and can only be viewed and changed within that routine. |
|
|
|